// mobile bind
// ============

define(['zepto', 'utils', 'sui'], function($, utils){
  return {
    init: function(data) {
      if(location.href.indexOf("#reloaded")==-1){
        location.href=location.href+"#reloaded";
        location.reload();
      }
      this.logout();
    },
    logout: function() {
      var that = this
      $(document).on('click', '#logout', function(e){
        e.preventDefault();
        defer = $.Deferred()
        $.showIndicator()
        $.post(window.__CTX__.root + '/logout')
            .done(function(response) {
              debugger
              $.hideIndicator()
              utils.processResult(response, function(result) {
                $.toast(result.message || '登出成功')
                defer.resolve(result.data)
                setInterval(function () {
                  window.location.href = window.__CTX__.root + "/cars/search"
                }, 2000)
              })
            })
        return defer.promise()
      })
    }
  }
})